home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Unix / gopher+1.2b4 / object / BLblock.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-26  |  2.9 KB  |  125 lines

  1. /********************************************************************
  2.  * lindner
  3.  * 3.2
  4.  * 1993/03/26 19:50:41
  5.  * /home/mudhoney/GopherSrc/CVS/gopher+/object/BLblock.h,v
  6.  * Exp
  7.  *
  8.  * Paul Lindner, University of Minnesota CIS.
  9.  *
  10.  * Copyright 1991, 1992,1993 by the Regents of the University of Minnesota
  11.  * see the file "Copyright" in the distribution for conditions of use.
  12.  *********************************************************************
  13.  * MODULE: BLblock.h
  14.  * Header file and abstraction of a gopher+ block
  15.  *********************************************************************
  16.  * Revision History:
  17.  * BLblock.h,v
  18.  * Revision 3.2  1993/03/26  19:50:41  lindner
  19.  * Mitra fixes for better/clearer fromNet code
  20.  *
  21.  * Revision 3.1.1.1  1993/02/11  18:03:06  lindner
  22.  * Gopher+1.2beta release
  23.  *
  24.  * Revision 1.1  1993/01/31  00:31:12  lindner
  25.  * Initial revision
  26.  *
  27.  *
  28.  *********************************************************************/
  29.  
  30.  
  31. #ifndef BLBLOCK_H
  32. #define BLBLOCK_H
  33.  
  34. #include "STRstring.h"
  35. #include "STAarray.h"
  36. #include "boolean.h"
  37.  
  38.  
  39. /** Return Values for *fromNet() functions **/
  40. #define SOFTERROR -1
  41. #define HARDERROR -2
  42. #define MORECOMING 1
  43. #define FOUNDEOF 0
  44.  
  45.  
  46. typedef struct block_struct Blockobj;
  47. typedef DynArray BlockArray;
  48. #include "GSgopherobj.h"
  49.  
  50.  
  51. /** The different types of blocks **/
  52. #define BLOCK_UNKNOWN  0
  53. #define BLOCK_VIEW     1
  54. #define BLOCK_ASK      2
  55. #define BLOCK_ABSTRACT 3
  56. #define BLOCK_ADMIN    4
  57.  
  58. typedef int BlockType;
  59.  
  60.  
  61. /** The block data is a union, it can either be a filename or the
  62.  ** actual data in a STRarray, or a gopher reference.
  63.  **/
  64.  
  65. union BlockData_union {
  66.      String      *filename;
  67.      StrArray    *text;
  68.      GopherObj   *gs;
  69. };
  70.  
  71. typedef union BlockData_union BlockData;
  72.  
  73.  
  74.  
  75. #define BDATA_NONE 0
  76. #define BDATA_FILE 1
  77. #define BDATA_TEXT 2
  78. #define BDATA_GREF 3
  79. typedef int BlockDataType;
  80.  
  81.  
  82. struct block_struct
  83. {
  84.      BlockType     btype;
  85.      String        *Blockname;
  86.      BlockDataType datatype;
  87.      BlockData     data;
  88. };
  89.  
  90.  
  91. /****** Macros/data access ********/
  92. #define BLgetName(a)        (STRget((a)->Blockname))
  93. #define BLsetName(a,b)      (STRset((a)->Blockname,(b)))
  94.  
  95. #define BLgetBlocktype(a)   (STRget((a)->btype))
  96. #define BLsetBlocktype(a,b) (STRset((a)->btype,(b)))
  97.  
  98. #define BLgetDatatype(a)    ((a)->datatype)
  99.  
  100. /**** Prototype declarations. ****/
  101. Blockobj *BLnew();
  102. void      BLdestroy();
  103. void      BLinit();
  104. void      BLcpy();
  105. void      BLsetFile();
  106. void      BLsetGref();
  107. void      BLsetText();
  108. char *    BLgetLine();
  109.  
  110. /*************************************************************
  111.  ** Define a dynamic block array
  112.  **/
  113.  
  114. #include "DAarray.h"
  115.  
  116. #define BLAnew(a)       (DAnew((a),BLnew,BLinit,BLdestroy,BLcpy))
  117. #define BLAinit(a)       (DAinit((a)))
  118. #define BLAgetTop(a)     (DAgetTop(a))
  119. #define BLAgetEntry(a,b) (Blockobj*)(DAgetEntry(a,b))
  120. #define BLApush(a,b)     (DApush((DynArray*)(a),(b)))
  121. #define BLAdestroy(a)    (DAdestroy(a))
  122. #define BLAcpy(a,b)      (DAcpy(a,b))
  123.  
  124. #endif
  125.